﻿using _09_1对多.M_1对1;
using _09_1对多.M_多对多;
using _09_1对多.乐观并发;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _09_1对多
{
    public class MyDbConetent:DbContext
    {
        // 1对多 ======================================
        public DbSet<OrgUnit> OrgUnits { get; set; }
        public DbSet<Leave> Leaves { get; set; }
        public DbSet<User> Users { get; set; }
        public DbSet<Article> Articles { get; set; }
        public DbSet<Comment> Comments { get; set; }
        // ===========================================

        // 1对1=======================================
        public DbSet<Order> Orders { get; set; }
        public DbSet<Delivery> Deliveries { get; set; }
        // ===========================================

        // 多对多=======================================
        public DbSet<Teacher> Teachers { get; set; }
        public DbSet<Student> Students { get; set; }
        // ===========================================

        public DbSet<Hours> Hours { get; set; }
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);
            optionsBuilder.UseSqlServer("server=.;database=coreTest;Trusted_Connection=True;MultipleActiveResultSets=true");
           //  optionsBuilder.LogTo(Console.WriteLine);
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            // 从当前程序集中加载所有的IEntityTypeConfiguration
            modelBuilder.ApplyConfigurationsFromAssembly(this.GetType().Assembly);
        }
    }
}
